package com.applets.yidiantong.service.impl;

import com.applets.yidiantong.pojo.News;
import com.applets.yidiantong.mapper.NewsMapper;
import com.applets.yidiantong.pojo.ServiceResult;
import com.applets.yidiantong.service.NewsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 咨询类 服务实现类
 * </p>
 *
 * @author zhaoyang
 * @since 2020-10-20
 */
@Service
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {

    @Autowired(required = false)
    NewsMapper newsMapper;

    //查询咨询
    public ServiceResult<IPage<News>> searchNews(Integer page, Integer limit) {
        QueryWrapper<News> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("isTop");
        Page<News> iPage = new Page<News>(page, limit);
        IPage<News> newsIPage = newsMapper.selectPage(iPage, queryWrapper);
        return ServiceResult.of(newsIPage,newsIPage.getSize()>0);
    }


}
